Silverlight 4.0: How to convert byte[] to image?

Posted by xscape on Stack Overflow See other posts from Stack Overflow or by xscape
Published on 2010-03-15T06:27:20Z Indexed on 2010/03/15 6:29 UTC
Read the original article Hit count: 309

public Image Base64ToImage(string base64String)
    {
        // Convert Base64 String to byte[]
        byte[] imageBytes = Convert.FromBase64String(base64String);
        MemoryStream ms = new MemoryStream(imageBytes, 0,
          imageBytes.Length);

        // Convert byte[] to Image
        ms.Write(imageBytes, 0, imageBytes.Length);
        System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
        return image;
    }

I want to convert byte[] to image, however System.Drawing.Image is not supported in Silverlight. Any alternative?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about 4.0